 @section('title')
 {{ $cat_name }} @parent
@show
@section('content')      
<div class="navbar theme-white">
	<div class="navbar-inner">
		<div class="center sliding">{{ $cat_name }}</div>
	</div>
</div>
	
<div class="pages navbar-through toolbar-through">
	<div data-page="info-index" class="page pb60">
		<form class="searchbar searchbar-init">
			<div class="searchbar-input">
			<input type="search" placeholder="关键字" class="kewword" value="{{ Input::get('keyword')  }}"><a class="searchbar-clear" href="#"></a>
			</div><a class="searchbar-cancel" href="#" style="display: block; margin-right: 0px;">取消</a>
			</form>
			<div class="searchbar-overlay"></div>
        <div class="page-content pull-to-refresh-content infinite-scroll">
            <div class="pull-to-refresh-layer">
                <div class="preloader"></div>
                <div class="pull-to-refresh-arrow"></div>
            </div>
				<p class="buttons-row tab-row">
				<a href="{{ route('info.index') }}" class="tab-link button @if(empty($cat))active @endif">资讯</a>
				<a href="{{ route('info.index', 'law') }}" class="tab-link button @if($cat == 'law')active @endif">法规</a>
				<a href="{{ route('info.index', 'case') }}" class="tab-link button @if($cat == 'case')active @endif">案例</a>
				<a href="{{ route('info.index', 'library') }}" class="tab-link button @if($cat == 'library')active @endif">文库</a>
				</p>            
				
				<div class="list-block media-list searchbar-found">
					@if(empty($cat))<ul class="info zs">@else<ul class="zs ask">@endif
						@if($articles)
						@foreach($articles AS $article)
						@if(empty($cat))
						<li class="swipeout" data-id="">
						<a href="{{ route('info.detail',$article->id) }}" class="external item-link item-content">
							<div class="item-media"><img class="lazy" data-src="{{ Config::get('app.img_url').$article->img }}" width="80"></div>
							<div class="item-inner">
							  <div class="item-title-row">
								<div class="item-title">{{ $article->title }}</div>
							  </div>
							  <div class="item-text">{{ $article->info }}</div>
							</div>
						  </a>
						</li>
						@else
						<li class="swipeout" data-id="">
							<a class="external item-link" href="{{ route('info.detail',$article->id) }}">
								<div class="item-content">
									<div class="item-inner search-inner">
										<div class="item-title" style="white-space: normal; padding-right:10px;">{{ $article->title }}</div>
										<div class="item-subtitle">{{ $article->created_at }}</div>
									</div>
								</div>
							</a>
						</li>
						@endif
						@endforeach
						@endif
					</ul>
				</div>	
		</div>
	</div>
</div>
@include('widgets.toolbar', array('active'=>'info'))
@stop
@section('bodyEnd')
{{ HTML::script("js/geo.js") }}
<script>
$$(document).on('keyup', '.kewword', function(){
		keyword = $$(this).val();
		if($$(this).val())
		{
			$$('.searchbar').addClass('searchbar-not-empty');
		}

		loading = true;
		search();
});
$$(document).on('click', '.searchbar-clear', function(){
			$$('.searchbar').removeClass('searchbar-not-empty');
})
	
var loading = false;
var page = {{ $page }};
var total_page =  {{ $total_page }};
var keyword =  '{{ $keyword }}';

     var ptrContent = $$('.pull-to-refresh-content');
     ptrContent.on('refresh', function (e) {
         $$.ajax({
             type: "get",
             url: window.location.href,
             success: function(response){
                 var _modal = document.createElement('div');
                 $$('.pages .searchbar-found').html($$(_modal).append(response).find('.pages .searchbar-found').html());
                 myApp.pullToRefreshDone();
             }
         });
     });

     var search = function(){
         var url =String('{{ route("info.index", $cat) }}');
         location.href = url + '?keyword='+keyword;
     }

     $$('.infinite-scroll').on('infinite', function () {
         if (loading) return;
         loading = true;
         if (page >= total_page) {
             // 加载完毕，则注销无限加载事件，以防不必要的加载
             myApp.detachInfiniteScroll($$('.infinite-scroll'));
             // 删除加载提示符
             $$('.infinite-scroll-preloader').remove();
             return;
         }
         page++;
				 ajax();

     });

		 var ajax = function(){
		     $$.ajax({
             type: "get",
             url: "{{ route('info.index', $cat) }}",
             data: "page=" + page + '&keyword=' + keyword,
             success: function(response){
                 var _modal = document.createElement('div');
								 if(page==0)
								 {
									 $$('.pages .searchbar-found .zs').html($$(_modal).append(response).find('.pages .searchbar-found .zs').html());
								 } else {
									 $$('.pages .searchbar-found .zs').append($$(_modal).append(response).find('.pages .searchbar-found .zs').html());
								 }
                 $$('.infinite-scroll-preloader').remove();
                 loading = false;
             }
         });		 
		 }
 </script>
 @show